package com.sgg.springbootsgg001demo.config;


import com.alibaba.druid.FastsqlException;
import com.sgg.springbootsgg001demo.bean.Cat;
import com.sgg.springbootsgg001demo.bean.Dog;
import com.sgg.springbootsgg001demo.bean.User;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

@Import(FastsqlException.class)
@Configuration
public class AppConfig2 {

    @ConditionalOnBean(name = "com.alibaba.druid.FastsqlException")
    @Bean(name = "cat01")
    public Cat cat01() {
        return new Cat();
    }

    @ConditionalOnMissingBean(name = "com.alibaba.druid.FastsqlException")
    @Bean(name = "dog01")
    public Dog dog01() {
        return new Dog();
    }

    @ConditionalOnBean(name = "dog01")
    @Bean(name = "zhangsan")
    public User zhangsan() {
        return  new User();
    }

    @ConditionalOnMissingBean(name = "dog01")
    @Bean(name = "lisi")
    public User lisi() {
        return new User();
    }

}
